package com.gxg.dao;

import com.gxg.entities.Ptitle;
import com.gxg.repository.PtitleRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;


import java.util.List;

/**
 * By 李朋飞
 **/
@Repository
public class PtitleDao {
    @Autowired
    PtitleRepository ptitleRepository;
    public List<Ptitle> findByTeacherIdAndParentTitle(String parentTitle,String teacherId){
        return ptitleRepository.findByParentTitleAndTeacherId(parentTitle,teacherId);
    }
    public Ptitle save(Ptitle ptitle){
        return ptitleRepository.save(ptitle);
    }
    public List<Ptitle> findByTeacherId(String teacherId, Pageable pageable){
        return ptitleRepository.findByTeacherId(teacherId,pageable).getContent();
    }
    public List<Ptitle> findAll(Pageable pageable){
        return ptitleRepository.findAll(pageable).getContent();
    }
    public List<Ptitle> findByVideoClass(String videoClass, Pageable pageable){
        return ptitleRepository.findByVideoClass(videoClass,pageable).getContent();
    }
    public int countAll(){
        return ptitleRepository.countAll();
    }
    public int countByVideoClass(String videoClass){
        return ptitleRepository.countByVideoClass(videoClass);
    }
    public int countByTeacherId(String teacherId){
        return ptitleRepository.countByTeacherId(teacherId);
    }
    public List<Ptitle> findByTeacherId(String teacherId){
        return ptitleRepository.findByTeacherId(teacherId);
    }
}